<?php
/**
 *
 *
 * This file is part of Webappkit, a packages system for PHP web apps
 * @link http://webappkit.net
 * @package
 * @subpackage
 * @author J.Ducastel <nospam0@ducastel.name>
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */

/**
 * @property string $input_type
 */
class DjInput extends DjWidget {

    public function render($name, $value=null, $attributes=array()) {
        $out = '<input type="'.$this->input_type.'" '
        .'name="'.$name.'"'
        .$this->_renderId($name)
        .$this->_renderValue($value)
        .$this->_renderAttributes($attributes);
        return $out.' />';
    }

    protected function _renderValue($value) {
        if (is_string($value))
            return ' value="'.$value.'"';
        else return '';
    }
}

class DjTextInput extends DjInput {

    protected $input_type = 'text';

}

class DjCheckBoxInput extends DjInput {

    protected $input_type = 'checkbox';

    public function render($name, $value=null, $attributes=array()) {
        return '<input type="checkbox" name="'.$name.'" value="1"'
        .$this->_renderId($name)
        .$this->_renderAttributes($attributes)
        .' />';
    }
}

/**
 * @property string $format
 */
class DjDateInput extends DjTextInput {

}

class DjFileInput extends DjInput {
    protected $input_type = 'file';
}